package com.example.tests;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import java.util.Set;

import org.testng.annotations.Test;

public class ContactModificationTests extends TestBase {
	@Test(dataProvider = "randomContacts")
	public void ContactModificationTest(ContactObject validContact, int contactNumber) throws Exception {
		Set<ContactObject> oldList = app.getContactHelper().getContacts();
		//TODO get random contact to modify
		app.getContactHelper().modifyContact(contactNumber, validContact);
		Set<ContactObject> newList = app.getContactHelper().getContacts();
		verifyContactModified(oldList, validContact, newList);
	}
		private void verifyContactModified(Set<ContactObject> oldList,
			ContactObject validContact, Set<ContactObject> newList) {
			assertThat(newList.size(), equalTo(oldList.size()));
			validContact.setFullName(validContact.getFirstName() + " " + validContact.getLastName());
			boolean matcher = newList.contains(validContact);
		    assertThat("objectInList", matcher); 
	}
}
